
import javax.media.*;

public class RTPClient implements ControllerListener, Runnable {

	Player p;
	MediaLocator src;
	String url;

	public static void main(String[] args) {
		startStream("rtp://10.11.38.80:8324/audio/");
	
	}
	public static void startStream(String url) {
		//"rtp://10.11.38.80:6532/audio/"
			RTPClient client = new RTPClient(url);
			Thread t = new Thread(client);
			t.run();
		
	}

	public RTPClient(String url) {
		this.url = url;
	}
	public void run() {
		try {
			MediaLocator ml = new MediaLocator(url);
			System.out.println("CREATE PLAYER");
			p = Manager.createPlayer(ml);
			p.addControllerListener(this);
			
			System.out.println("TRYING TO BEGIN");
			p.start();
		} catch(Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public synchronized void connectionError(ConnectionErrorEvent evt){
		System.out.println(evt);
	}
	
	public synchronized void controllerUpdate(ControllerEvent evt) {
		if (evt instanceof EndOfMediaEvent) {
			
		} else {
			System.out.println(evt.toString());
		}
	}
}  